using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;

namespace CSP.DataAccess.Mapping
{
    public class ContactWayMap : EntityTypeConfiguration<ContactWay>
    {
        public ContactWayMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.username)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.nickname)
                .HasMaxLength(20);

            this.Property(t => t.address)
                .HasMaxLength(50);

            this.Property(t => t.lastmodified)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(8)
                .IsRowVersion();

            // Table & Column Mappings
            this.ToTable("ContactWay");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.username).HasColumnName("username");
            this.Property(t => t.nickname).HasColumnName("nickname");
            this.Property(t => t.address).HasColumnName("address");
            this.Property(t => t.type).HasColumnName("type");
            this.Property(t => t.orderId).HasColumnName("orderId");
            this.Property(t => t.lastmodified).HasColumnName("lastmodified");
        }
    }
}
